package com.example.instantmessage;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import com.tencent.imsdk.v2.V2TIMFriendAddApplication;
import com.tencent.imsdk.v2.V2TIMFriendOperationResult;
import com.tencent.imsdk.v2.V2TIMManager;
import com.tencent.imsdk.v2.V2TIMValueCallback;

public class AddFriendsActivity extends AppCompatActivity {
    private TextView addFriendsTv;
    private EditText addFriendsEt;
    private Button addFriendsBtn;
    private String userID;
    V2TIMFriendAddApplication application;
    private static final String TAG = "AddFriendsActivity";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_add_friends);
        addFriendsTv = findViewById(R.id.add_friends_id_tv);
        addFriendsEt = findViewById(R.id.add_friends_id_et);
        addFriendsBtn = findViewById(R.id.add_friends_id_btn);

        addFriendsBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                userID = addFriendsEt.getText().toString();

//                application = new V2TIMFriendAddApplication(userID);
                application.setUserID(userID);
                Log.i(TAG, "onClick: 111111111111111111111111111");
                V2TIMManager.getFriendshipManager().addFriend(application, new V2TIMValueCallback<V2TIMFriendOperationResult>() {
                    @Override
                    public void onSuccess(V2TIMFriendOperationResult v2TIMFriendOperationResult) {
                        Log.i(TAG, "onSuccess: ");
                    }

                    @Override
                    public void onError(int code, String desc) {
                        Log.e(TAG, "onError: 22222222222222222222222");
                    }
                });

            }
        });
    }
}